<template>
  <div class="app-container">
    <div class="tab">
      <div class="active">
        <router-link to="contractList">
          合同概况
        </router-link>
      </div>
      <div>罚款管理</div>
      <div>工程签证管理</div>
      <div>索赔(反索赔)管理</div>
      <div>赢得值法应用管理</div>
      <div>请款条件管理</div>
      <div>进度款请(收)款管理</div>
      <div>作业队支付管理</div>
      <div>供应商支付管理</div>
      <div>官方奖惩费用管理</div>
    </div>
    <div v-permission="['progress:create']" class="createManager">
      <router-link to="createProgress">
        <div style="margin: 0 0 0 -5px;" class="addbtn">新增</div>
      </router-link>
    </div>
    <div class="seatch">
      <el-input
        v-model="listQuery.keyword"
        placeholder="按操作人搜索"
        @keyup.enter.native="searchName($event)"
      >
        <i slot="prefix" class="el-input__icon el-icon-search" @click="getList()" />
      </el-input>
    </div>
    <div class="content">
      <el-table
        v-loading="listLoading"
        align="center"
        :data="tableData"
        style="width: 100%"
      >
        <el-table-column
          label="序号"
          width="70px"
        >
          <template slot-scope="scope">
            {{ scope.$index+1 }}
          </template>
        </el-table-column>
        <el-table-column
          prop="name"
          align="center"
          label="里程碑名称"
        />
        <el-table-column
          prop="constructionPeriod"
          align="center"
          label="工期"
        />
        <el-table-column
          align="center"
          prop="stage"
          label="阶段"
        />
        <el-table-column
          align="center"
          prop="startTime"
          label="开始时间"
        />
        <el-table-column
          align="center"
          prop="completionTime"
          label="竣工时间"
        />
        <el-table-column
          align="center"
          prop="createAt"
          label="操作"
          width="100px"
        >
          <template slot-scope="{row}">
            <div class="operate">
              <div title="详情">
                <router-link :to="{ path: 'detailProgress', query: { id: row.id }}">
                  <img src="@/assets/images/detail.png" alt="">
                </router-link>
              </div>
              <div title="编辑">
                <router-link :to="{ path: 'edgeProgress', query: { id: row.id }}">
                  <img src="@/assets/images/edit.png" alt="">
                </router-link>
              </div>
              <div title="删除" @click="deleteDialog(row)">
                <img src="@/assets/images/delete-img.png" alt="">
              </div>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pageination-div">
        <pagination v-show="total>0" :total="total" :page.sync="listQuery.pageNum" :limit.sync="listQuery.pageSize" @pagination="getList" />
      </div>
      <delete-dialog
        dislog-name="里程碑"
        :dialog-del-visible="dialogDelVisible"
        :title="'里程碑'"
        @funcancl="funcancl"
        @func="deleteData"
      />
    </div>

  </div>

</template>

<script>
import { Message } from 'element-ui'
import Pagination from '@/components/pagination'
import DeleteDialog from '@/components/dialog/delete'
import { progress, deleteManagerment } from '@/api/progressManagement'
export default {
  components: {
    Pagination,
    DeleteDialog
  },
  data() {
    return {
      tableData: [],
      total: 0,
      listLoading: true,
      listQuery: {
        keyword: null,
        pageNum: 1,
        pageSize: 10
      },
      deleteObiect: {},
      dialogDelVisible: false
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    sizeChange(val) {
      this.pageNum = val
    },
    currentChange(val) {
      this.currentPage = val
    },
    searchName(e) {
      this.listQuery.keyword = e.target.value
      this.getList()
    },
    funcancl(val) {
      this.dialogDelVisible = false
    },
    // 获取数据
    async getList() {
      const res = await progress(this.listQuery)
      this.listLoading = false
      if (res.code === 200) {
        this.tableData = res.data.list
        this.total = res.data.total || 0
        this.pages = res.data.pages || 0
      } else {
        Message({
          message: res.data.msg || 'error',
          type: 'error',
          showClose: true,
          duration: 2 * 1000
        })
      }
    },
    // 删除
    deleteDialog(row) {
      this.dialogDelVisible = true
      this.deleteObiect = row
    },
    async deleteData(row) {
      const id = this.deleteObiect.id
      const res = await deleteManagerment([id])
      if (res.code === 200) {
        this.getList()
        this.dialogDelVisible = false
        this.$message({
          type: 'success',
          message: '删除成功!',
          showClose: true,
          center: true,
          duration: 2 * 1000
        })
      } else {
        this.dialogDelVisible = false
      }
    }
  }
}
</script>
<style lang="scss" scoped>
@import '../../../styles/variables';
.app-container{
  .tab{
    font-size:14px;
    font-weight: 400;
    color: #ffffff;
    display: flex;
    div{
      cursor: pointer;
      margin:10px 5px 0 20px;
    }
    .active{
      padding-bottom: 7px;
      border-bottom: 1.5px solid #F7B500;
    }
  }
  .createManager{
    position: absolute;
    margin: 13px 0 0 26px;
    font-size:$fontSize14;
    font-weight:400;
    color:rgba(255,255,255,0.65);
   button{
      background:$btnactiveColor !important;
   }
  }
  .content{
    .operate{
      display: flex;
      font-size:$fontSize12;
      font-weight:400;
      color:rgba(247,181,0,1);
      div{
        cursor: pointer;
        flex: 1;
      }
    }
  }
}
</style>
